import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from "../views/Index"
import Home from '../views/Home.vue'
import Manage from "../views/Manage"
import ShoppingCart from "../views/ShoppingCart"
import Search from "../views/Search";
import UploadCommodity from "../views/UploadCommodity"

Vue.use(VueRouter)
const routes = [
  {
    path: '/manage',
    redirect: '/home',
  },
  {
    path: '/',
    redirect: '/index',
  },
  {
    path: '/index',
    name: 'Index',
    component: Index,
    meta: {
      title: '登录页面！'
    }
  },


  {
    path: '/manage',
    name: 'Manage',
    component: Manage,
    meta: {
      title: '欢迎！'
    },
    children:[
        {
      path: '/home',
      name: 'Home',
      component: Home,
      meta: {
        title: '这是主页哒！'
      }
    },
      {
        path: '/shopping_cart',
        name: 'ShoppingCart',
        component: ShoppingCart,
        meta: {
          title: '购物车！'
        }
      },
      {
        path: '/upload_commodity',
        name: 'upload_commodity',
        component: UploadCommodity,
        meta: {
          title: '上传商品！'
        }
      },
      {
        path: '/search',
        name: 'Search',
        component: Search,
        meta: {
          title: '搜索！'
        }
      },
      {
        path: '/about/:id/:data_name',
        name: 'About',
        meta: {
          title: '详细！'
        },

        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
      }


      ]
  },
]

const router = new VueRouter({
  routes
})

export default router
